L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack']
print(L[-2:])
print(L[:-2])
print(L[:])
print(L[0:])
print(L[:4])
y = list(range(100))
print(y)
print(y[-5:])


# 练习 利用切片操作，实现一个trim()函数，去除字符串首尾的空格，注意不要调用str的strip()方法：
def trim(s):
    if s == '':
        return s
    else:
        if s[0] == ' ' or s[-1] == ' ':
            if s[0] == ' ':
                s = s[1:]
                if s[-1] == ' ':
                    s = s[:-1]
            else:
                s = s[:-1]
            return trim(s)
        else:
            return s


print(trim(' hh'))
